/*==============================================================================
**                                  Cuong Chu
**                      Proprietary - Copyright (C) 2014
**------------------------------------------------------------------------------
** Supported MCUs      : MCU STM32
** Supported Compilers : KeilC
**------------------------------------------------------------------------------
** File name         : LCD.h
**  
** Module name       : LCD 16x2 interface
**
** Summary: Header file of LCD 16x2 driver
**
**= History ===================================================================
** 00.00.01  17/7/2014  Cuong Chu
** - Creation
==============================================================================*/
#ifndef __DV_LCD_H__
#define __DV_LCD_H__
/******************************************************************************/
/* INCLUSIONS                                                                 */
/******************************************************************************/
#include "stdint.h"
/******************************************************************************/
/* DEFINITION OF TYPES                                                        */
/******************************************************************************/
typedef enum
{
  LCD_OK,
  LCD_NULL_PTR,
  LCD_INVALID_CMD,
  LCD_INVALID_LINE
}LCD_ReturnType;
 
#define LCD_CMD_INSTRUCT_COMP       0x03
#define LCD_CMD_MODE_4BIT           0x02
#define LCD_CMD_LCD_5X8             0x28
#define LCD_CMD_CURSOR_DISABLE      0x0c
#define LCD_CMD_CURSOR_ENABLE       0x0f
#define LCD_CMD_CLRSCR              0x01
#define LCD_CMD_LINE1               0x80
#define LCD_CMD_LINE2               0xc0
#define LCD_CMD_LINE3               0x94
#define LCD_CMD_LINE4               0xd4
/* LCD number of line */  
#define LCD_TYPE_NBR_OF_LINE        4
/* LCD screen size */
#define LCD_TYPE_SCR_SIZE           20
/*******************************************************************************/
/* DECLARATION OF GLOBAL FUNCTIONS                                             */
/*******************************************************************************/
/*******************************************************************************
** Function name: LCD_StartDisplay( void  )
** Description  : The function starting display          
** Parameter    : none
** Return value : none
** Remarks      : global variables used, side effects
*******************************************************************************/
void LCD_StartDisplay
(
  void
);
/*******************************************************************************
** Function name: LCD_ClearScreen( void  )
** Description  : The function clear screen
** Parameter    : none
** Return value : none
** Remarks      : global variables used, side effects
*******************************************************************************/
void LCD_ClearScreen
(
  void
);
/*******************************************************************************
** Function name: LCD_SetCursorFirst( uint8_t line  )
** Description  : The function set cursor at first of line
** Parameter    : none
** Return value : none
** Remarks      : global variables used, side effects
*******************************************************************************/
void LCD_SetCursorFirst
(
  uint8_t line
);
/*******************************************************************************
** Function name: LCD_SetCursorPosition( uint8_t X,
**                                       uint8_t Y )
** Description  : The function set cursor at position 
** Parameter    : none
** Return value : none
** Remarks      : global variables used, side effects
*******************************************************************************/
void LCD_SetCursorPosition
(
  uint8_t X,
  uint8_t Y
);
/*******************************************************************************
** Function name: LCD_WriteData( uint8_t data  )
** Description  : The function write data to LCD          
** Parameter    : data - data write to LCD
** Return value : none
** Remarks      : global variables used, side effects
*******************************************************************************/
void LCD_WriteData
(
  uint8_t data
);
/*******************************************************************************
** Function name: LCD_WriteCmd( uint8_t cmd )
** Description  : The function write command to LCD          
** Parameter    : cmd - command write to LCD
** Return value : LCD_ReturnType - LCD_OK if processes success
**                                 LCD_INVALID_CMD if processes failed
** Remarks      : global variables used, side effects
*******************************************************************************/
LCD_ReturnType LCD_WriteCmd
(
  uint8_t cmd
);
/******************************************************************************
** Function name: LCD_EnableCursor()
** Description: The function enable cursor display
** Parameter X : None
** Return value: None
** Remarks: global variables used, side effects
******************************************************************************/
void LCD_EnableCursor
(
  void
);
/******************************************************************************
** Function name: LCD_DisableCursor()
** Description: The function disable cursor display
** Parameter X : None
** Return value: None
** Remarks: global variables used, side effects
******************************************************************************/
void LCD_DisableCursor
(
  void
);
/*******************************************************************************
** Function name: LCD_Printf( uint8_t* str )
** Description  : The function write string to LCD          
** Parameter    : str - string write to LCD
** Return value : none
** Remarks      : global variables used, side effects
*******************************************************************************/
void LCD_Printf
(
  uint8_t* str
);
#endif /* __DV_LCD_H__ */
